Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freedom noises: Support "hex" as type & packet #4239

Merged
merged 3 commits into from
Jan 2, 2025

Conversation

GFW-knocker
Copy link
Contributor

@GFW-knocker GFW-knocker commented Jan 1, 2025

add option for hex noise.

we need to send noise packet in hex
for example :
QUIC header "ee0000000108aaaaaaaaaaaaaaaa000044d0" in hex
can't be represented in str or base64 with printable chars.

to see difference please check packets in wireshark with this config

this pr solve this issue: #4237

add option for hex noise
@GFW-knocker GFW-knocker mentioned this pull request Jan 1, 2025
4 tasks
@Fangliding
Copy link
Member

Any binary data can be encoded as base64 (in your example 7gAAAAEIqqqqqqqqqqqqqqqoAAETQ), the only problem is that the output from the log is incorrect, and you are even continuing to use the wrong variable name

@Fangliding Fangliding closed this Jan 2, 2025
@GFW-knocker
Copy link
Contributor Author

@Fangliding
i'm not talking about output log
i'm talking about actual packets sent in network
please see packets in wireshark

when you send str or base64 ,
it converted to utf-8 before sent but we need raw hex

example:
str "ee00" --> byte[] {0x65,0x65,0x30,0x30}
hex "ee00" --> byte[] {0xee,0x00}

(also 7gAAAAEIqqqqqqqqqqqqqqqoAAETQ is not a valid base64 ! but even if so, it sent in utf-8)

@Fangliding
Copy link
Member

Fangliding commented Jan 2, 2025

配置文件中可以指定是直接发送str(utf8)抑或是将输入的base64解码为byte并发送
base64除了编码文本还被用于编码字节数据用于在纯文本环境传递(实际上它编码的一直都是字节数据) 你觉得这是无效的base64 因为你只知道它可以编码文本
名字起个 GFW-knocker 结果只会摆弄那几个wireshark输出结果连这么基本的编码知识都不知道 说两遍说三遍听不懂 真不怕被笑话

@RPRX
Copy link
Member

RPRX commented Jan 2, 2025

base64 被发明出来就是用于编码 bytes 非可打印字符的,否则它和 str 有什么区别,并且 base64 比 hex 更紧凑(占用空间更少)

不过 hex 的好处是可读性更高,加一个 hex 也不是不可以,但这并不意味着你的说法是对的

@GFW-knocker
Copy link
Contributor Author

@Fangliding

yes you are right. we can convert hex to base64
i made a mistake because some online tools convert it incorrectly

even your base64 conversion is invalid
7gAAAAEIqqqqqqqqqqqqqqqoAAETQ

i put in the config:
{ "type":"base64", "packet":"7gAAAAEIqqqqqqqqqqqqqqqoAAETQ", "delay":"10-16" },
i get:
infra/conf: Invalid base64 string

the question is why we don't accept hex ?
wouldn't be easier to have hex option too?

@RPRX
Copy link
Member

RPRX commented Jan 2, 2025

@GFW-knocker rebase 一下

@RPRX RPRX reopened this Jan 2, 2025
@RPRX
Copy link
Member

RPRX commented Jan 2, 2025

@GFW-knocker 能开放你的仓库的修改权限吗

@RPRX
Copy link
Member

RPRX commented Jan 2, 2025

@GFW-knocker 或者你把我设为 collaborator

@Fangliding
Copy link
Member

@Fangliding

yes you are right. we can convert hex to base64 i made a mistake because some online tools convert it incorrectly

even your base64 conversion is invalid 7gAAAAEIqqqqqqqqqqqqqqqoAAETQ

i put in the config: { "type":"base64", "packet":"7gAAAAEIqqqqqqqqqqqqqqqoAAETQ", "delay":"10-16" }, i get: infra/conf: Invalid base64 string

the question is why we don't accept hex ? wouldn't be easier to have hex option too?

I am not against this feature. The reason why I closed PR is that it cannot fix the issue and conflicts with the real fix

@GFW-knocker
Copy link
Contributor Author

GFW-knocker commented Jan 2, 2025

@GFW-knocker 或者你把我设为 collaborator

@RPRX
i invite you as collaborator
thank you

@RPRX RPRX changed the title Freedom config: add hex option to udp noise Freedom noises: Add hex to type Jan 2, 2025
@RPRX RPRX changed the title Freedom noises: Add hex to type Freedom noises: Support "hex" as type & packet Jan 2, 2025
@RPRX RPRX merged commit ca50c9c into XTLS:main Jan 2, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants